home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / tpfort17.zip / FORTLINK.DOC < prev    next >
Text File  |  1991-07-08  |  3KB  |  79 lines

  1. unit FortLink;
  2.  
  3. { TPFORT unit to link in fortran routines.  See TPFORT.DOC for instructions. }
  4. { This file contains the interface section only.                             }
  5. { Version 1.7 - added FortErrorFlag }
  6. { Version 1.5 - added Ext_Pointer function                                   }
  7. { Version 1.4 - added Size_Table types and variable for CHARACTER support    }
  8. { Version 1.3 - fixed bug in loader, and changes type of extra_space to
  9.                 longint }
  10.  
  11. interface
  12.   uses Dos;
  13.  
  14. type
  15.   Extval     = longint;
  16.   Double_Ptr = ^double;
  17.   RealArray  = array[1..65520 div sizeof(double)] of double;
  18.   Size_Table_Array = array[0..65519 div sizeof(word)] of word;
  19.                      { Array of CHARACTER variable sizes.  Note that entry
  20.                        0 seems to be unused. }
  21.   Size_Table_Ptr = ^Size_Table_Array;
  22.  
  23. const
  24.   MaxProcs  = 32;  { Recompile this as large as necessary.
  25.                      Overhead is 4*maxprocs }
  26.   Extra_Space : longint = 1024;{ Extra space for the Fortran loader's heap.
  27.                                 Increase if loadfort fails with Exec error 8
  28.                                 or Fortran complains }
  29.   LinkedProcs   : word = 0;  { The number of procedures linked so far.  Use
  30.                                for automatic procedure numbering in unit
  31.                                initializations }
  32. var
  33.   FortLoaded    : boolean;   { True indicates Fortran routines are in memory }
  34.   FortSafe      : boolean;   { True indicates you're in Fortran mode }
  35.   Size_Table    : ^Size_Table_Ptr; { Points to __fcclenv; see docs. }
  36.  
  37.  
  38. function LoadFort(Prog:string;TPentry:pointer):boolean;
  39. { The procedure to load the fortran routines.  Returns true on success. }
  40.  
  41. procedure CallFort(ProcNum:word);
  42. { The procedure to call the Fortran routine number procnum }
  43. { Works for SUBROUTINES and FUNCTIONS with values up to 4 bytes (except REAL*4)}
  44.  
  45. procedure FSingle(procnum:word);
  46. { Simulates a Fortran REAL*4 Function call }
  47.  
  48. procedure FDouble(procnum:word);
  49. { Simulates a Fortran Double Precision Function call }
  50.  
  51. procedure FPointer(procnum:word);
  52. { Simulates a Fortran Function call with a value up to 8 bytes long, by
  53.   returning a pointer to it.  Can reserve space for longer return values by
  54.   passing multiple copies of the function to CALLTP, and only using the
  55.   first.
  56. }
  57.  
  58. function Fort_External(ProcNum:word):Extval;
  59. { Returns value to be passed as an external reference }
  60.  
  61. function Pas_External(Proc:pointer):Extval;
  62. { Returns value to be passed as an external reference for
  63.   a Pascal procedure or specially constructed function
  64. }
  65.  
  66. function Ext_Pointer(Ext:Extval):pointer;
  67. { Returns a pointer to the entry point of a routine passed as an Extval }
  68.  
  69. procedure Clean_External;
  70. { Routine to clean up stack after Fort_External or Pas_External }
  71.  
  72. procedure Enter_Pascal;
  73. { Set up Pascal context. Always pair with Leave_Pascal! }
  74.  
  75. procedure Leave_Pascal;
  76. { Restore Fortran context. Always pair with Enter_Pascal! }
  77.  
  78. 
  79.